import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

export namespace VillageInfo {
  /**查询参数 */
  export interface Query extends ReqPage {
    villageName?: string
    villageType?: number
    parentId?: number
  }

  /**列表内容 */
  export interface Record {
    id: number
    villageName: string
    villageType: number
    parentId: number
    registeredPopulation: number
    permanentPopulation: number
    labourForce: number
    longitude: string
    latitude: string
  }

  /**详情 */
  export interface Form {
    id: number
    villageName: string
    villageType: number
    parentId: number
    registeredPopulation: number
    permanentPopulation: number
    labourForce: number
    longitude: string
    latitude: string
    content: string
  }

  export const TypeEnum = [
    { value: 0, label: '行政村' },
    { value: 1, label: '自然村' }
  ]
}

// 分页查询
export const pageVillageInfo = (params: VillageInfo.Query) => {
  return http.get<ResPage<VillageInfo.Record>>(TBY + `/village_info/page`, params)
}

// 列表查询
export const listVillageInfo = (params: VillageInfo.Query) => {
  return http.get<VillageInfo.Record[]>(TBY + `/village_info/list`, params)
}

// 详情信息
export const getVillageInfoDetail = (id: number) => {
  return http.get<Partial<VillageInfo.Form>>(TBY + `/village_info/get`, { id }, { loading: false })
}

// 新增或修改
export const saveOrUpdateVillageInfo = (params: Partial<VillageInfo.Form>) => {
  return http.post(TBY + `/village_info/save`, params)
}

// 删除
export const removeVillageInfo = (id: number) => {
  return http.delete(TBY + `/village_info/delete`, { id })
}
